package com.joeyee.echartsgenerator.echarts.line;

import com.github.abel533.echarts.axis.CategoryAxis;
import com.github.abel533.echarts.axis.ValueAxis;
import com.github.abel533.echarts.code.Trigger;
import com.github.abel533.echarts.json.GsonOption;
import com.github.abel533.echarts.series.Line;
import com.joeyee.echartsgenerator.echarts.EnhancedOption;

/**
 * @author Joe Yee
 * @version 1.0
 * @description: TODO
 * @date 2021/8/11 14:37
 */
public class EchartBaseLine {

    public static GsonOption createLine(LineData lineData){
        EnhancedOption option = new EnhancedOption();
        option.tooltip().trigger(Trigger.axis);
//        option.legend(lineData.getLineParam().getLegendName());
//        option.toolbox().show(true);
        option.calculable(true);
        option.xAxis(new CategoryAxis().boundaryGap(false).data(lineData.getLineParam().getName()));
        option.yAxis(new ValueAxis());
        Line line = new Line();
        if(lineData.isSmooth()){
            line.smooth(true);
        }
        line.data(lineData.getLineParam().getValue());
        //实现不了页面效果:https://echarts.apache.org/examples/zh/editor.html?c=area-basic
//        line.areaStyle(new AreaStyle());
        option.series(line);
        return option;
    }
}
